using AutoMapper;
using DMS.BEs;
using DMS.DTOs;

namespace DMS.Mappers.AutoMapper
{
    public class MapperBEtoDTO : IMapperBEtoDTO
    {
        public MapperBEtoDTO()
        {
            Mapper.CreateMap<Invoice, InvoiceDTO>();
            Mapper.CreateMap<Invoice, InvoiceWithLinesDTO>();
            Mapper.CreateMap<InvoiceLine, InvoiceLineDTO>()
                .ForMember(dto => dto.ArtistName, mc => mc.MapFrom(be => be.Track.Album.Artist.Name))
                .ForMember(dto => dto.AlbumTitle, mc => mc.MapFrom(be => be.Track.Album.Title));

            Mapper.CreateMap<Customer, CustomerDTO>();

			Mapper.CreateMap<Invoice, GiftDTO>();
        }

        public TD Map<TB, TD>(TB be) where TD : IDTO
        {
            return Mapper.Map<TB, TD>(be);
        }
    }
}